home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1993 July / InfoMagic USENET CD-ROM July 1993.ISO / sources / unix / volume12 / cnews / part04 < prev    next >
Encoding:
Internet Message Format  |  1987-10-19  |  54.1 KB

  1. Subject:  v12i029:  C News alpha release, Part04/14
  2. Newsgroups: comp.sources.unix
  3. Sender: sources
  4. Approved: rs@uunet.UU.NET
  5.  
  6. Submitted-by: utzoo!henry (Henry Spencer)
  7. Posting-number: Volume 12, Issue 29
  8. Archive-name: cnews/part04
  9.  
  10. #! /bin/sh
  11. # This is a shell archive.  Remove anything before this line, then unpack
  12. # it by saving it into a file and typing "sh file".  To overwrite existing
  13. # files, type "sh file -c".  You can also feed this as standard input via
  14. # unshar, or by typing "sh <file", e.g..  If this archive is complete, you
  15. # will see the following message at the end:
  16. #        "End of archive 4 (of 14)."
  17. PATH=/bin:/usr/bin:/usr/ucb ; export PATH
  18. if test -f 'COPYRIGHT' -a "${1}" != "-c" ; then 
  19.   echo shar: Will not clobber existing file \"'COPYRIGHT'\"
  20. else
  21. echo shar: Extracting \"'COPYRIGHT'\" \(1355 characters\)
  22. sed "s/^X//" >'COPYRIGHT' <<'END_OF_FILE'
  23. X/*
  24. X * Copyright (c) University of Toronto 1985, 1986, 1987.
  25. X * Written by Geoffrey Collyer and Henry Spencer.
  26. X * This software is not subject to any license of the American Telephone
  27. X * and Telegraph Company or of the Regents of the University of California.
  28. X *
  29. X * Permission is granted to anyone to use this software for any purpose on
  30. X * any computer system, and to alter it and redistribute it freely, subject
  31. X * to the following restrictions:
  32. X *
  33. X * 1. The authors are not responsible for the consequences of use of this
  34. X *    software, no matter how awful, even if they arise from flaws in it.
  35. X *
  36. X * 2. The origin of this software must not be misrepresented, either by
  37. X *    explicit claim or by omission.  Since few users ever read sources,
  38. X *    credits must appear in the documentation.
  39. X *
  40. X * 3. Altered versions must be plainly marked as such, and must not be
  41. X *    misrepresented as being the original software.  Since few users
  42. X *    ever read sources, credits must appear in the documentation.
  43. X *
  44. X * 4. This notice may not be removed or altered.
  45. X *
  46. X * 5. This release may be redistributed only in its original state:  existing
  47. X *    material (e.g. sources) may not be deleted, changes may not be made to
  48. X *    the originals, and new materials must be added as a supplementary
  49. X *    distribution rather than interspersed with the originals.
  50. X */
  51. END_OF_FILE
  52. if test 1355 -ne `wc -c <'COPYRIGHT'`; then
  53.     echo shar: \"'COPYRIGHT'\" unpacked with wrong size!
  54. fi
  55. # end of 'COPYRIGHT'
  56. fi
  57. if test -f 'batch/Makefile' -a "${1}" != "-c" ; then 
  58.   echo shar: Will not clobber existing file \"'batch/Makefile'\"
  59. else
  60. echo shar: Extracting \"'batch/Makefile'\" \(1567 characters\)
  61. sed "s/^X//" >'batch/Makefile' <<'END_OF_FILE'
  62. X# Configuration stuff.
  63. XCFLAGS=-O
  64. XLDFLAGS=-n
  65. XNEWSCTL=/usr/lib/news
  66. XNEWSARTS=/usr/spool/news
  67. XNEWSBIN=/usr/lib/newsbin
  68. X
  69. X# File lists.
  70. XPGMS=batchmake batchmunch batchprep batchsize batchxmit queuelen queuemax \
  71. X    roomfor sendbatches
  72. XALL=README dMakefile batchmake.c batchmunch batchprep batchsize batchxmit \
  73. X    newsbatch.8.p queuelen queuemax roomfor sendbatches teststuff \
  74. X    testmakefile
  75. XPLIST=README Makefile sendbatches batchmake.c batchmunch batchprep \
  76. X    batchsize batchxmit queuelen queuemax roomfor
  77. X
  78. Xthem:    batchmake newsbatch.8
  79. X
  80. Xbatchmake:    batchmake.o
  81. X    cc $(CFLAGS) $(LDFLAGS) batchmake.o -o $@
  82. X
  83. Xnewsbatch.8:    newsbatch.8.p muck
  84. X    sed -f muck newsbatch.8.p >$@
  85. X
  86. Xmuck:
  87. X    echo 's;\$$NEWSCTL;$(NEWSCTL);g' >muck
  88. X    echo 's;\$$NEWSARTS;$(NEWSARTS);g' >>muck
  89. X    echo 's;\$$NEWSBIN;$(NEWSBIN);g' >>muck
  90. X
  91. Xtidy:
  92. X    rm -f batchmake batchmake.o muck newsbatch.8
  93. X
  94. Xinstall:    $(PGMS) newsbatch.8 teststuff muck
  95. X    if test ! -d $(NEWSBIN)/batch ; then mkdir $(NEWSBIN)/batch ; fi
  96. X    cp $(PGMS) $(NEWSBIN)/batch
  97. X    cp newsbatch.8 /usr/man/man8
  98. X    if test ! -d $(NEWSCTL)/batch ; then mkdir $(NEWSCTL)/batch ; fi
  99. X    if test ! -d $(NEWSCTL)/batch/b.test ; then mkdir $(NEWSCTL)/batch/b.test ; fi
  100. X    cat teststuff | ( cd $(NEWSCTL)/batch/b.test ; sh )
  101. X    sed -f muck testmakefile >$(NEWSCTL)/batch/b.test/Makefile
  102. X    @echo 'To test, cd $(NEWSCTL)/batch/b.test and say "make".'
  103. X
  104. X# EXCISE
  105. X
  106. Xteststuff:
  107. X    cd b.test; makedtr * >../teststuff
  108. X
  109. Xdtr:    $(ALL)
  110. X    makedtr $(ALL) >dtr
  111. X
  112. XdMakefile:    Makefile
  113. X    sed '/^# EXCISE/,$$d; s/tidy/clean/' Makefile >$@
  114. X
  115. Xclean:    tidy
  116. X    rm -f teststuff dMakefile
  117. X
  118. Xprint:
  119. X    pr $(PLIST) | hpfour
  120. END_OF_FILE
  121. if test 1567 -ne `wc -c <'batch/Makefile'`; then
  122.     echo shar: \"'batch/Makefile'\" unpacked with wrong size!
  123. fi
  124. # end of 'batch/Makefile'
  125. fi
  126. if test -f 'gngp/gngp.c' -a "${1}" != "-c" ; then 
  127.   echo shar: Will not clobber existing file \"'gngp/gngp.c'\"
  128. else
  129. echo shar: Extracting \"'gngp/gngp.c'\" \(1988 characters\)
  130. sed "s/^X//" >'gngp/gngp.c' <<'END_OF_FILE'
  131. X/*
  132. X * gngp - globally find newsgroup and print
  133. X *    like grep, but for newsgroup patterns instead of regular expressions
  134. X */
  135. X
  136. X#include <stdio.h>
  137. X
  138. Xchar *progname;
  139. Xint debug = 0;
  140. X
  141. X/*
  142. X * if true, match only ng at start of line, followed by whitespace or newline.
  143. X */
  144. Xint anchored = 0;
  145. X
  146. XFILE *efopen();
  147. X
  148. X/*
  149. X * main - parse arguments and handle options
  150. X */
  151. Xmain(argc, argv)
  152. Xint argc;
  153. Xchar *argv[];
  154. X{
  155. X    int c, status = 0;
  156. X    int errflg = 0;
  157. X    FILE *in;
  158. X    extern int optind;
  159. X    extern char *optarg;
  160. X
  161. X    progname = argv[0];
  162. X    while ((c = getopt(argc, argv, "ad")) != EOF)
  163. X        switch (c) {
  164. X        case 'a':        /* anchored at start of line */
  165. X            anchored++;
  166. X            break;
  167. X        case 'd':
  168. X            matchdebug(1);    /* all debugging on */
  169. X            debug++;
  170. X            break;
  171. X        default:
  172. X            errflg++;
  173. X            break;
  174. X        }
  175. X    if (errflg || optind == argc) {
  176. X        (void) fprintf(stderr, "usage: %s [-ad] pattern [file...]\n",
  177. X            progname);
  178. X        exit(2);
  179. X    }
  180. X    if (optind == argc-1)
  181. X        status |= process(argv[optind], stdin, "stdin");
  182. X    else {
  183. X        int patind = optind;
  184. X
  185. X        for (optind++; optind < argc; optind++) {
  186. X            in = efopen(argv[optind], "r");
  187. X            status |= process(argv[patind], in, argv[optind]);
  188. X            (void) fclose(in);
  189. X        }
  190. X    }
  191. X    exit(status != 0? 0: 1);
  192. X}
  193. X
  194. X/*
  195. X * process - process input file
  196. X */
  197. Xprocess(pattern, in, inname)
  198. Xchar *pattern;
  199. XFILE *in;
  200. Xchar *inname;
  201. X{
  202. X    int status = 0;
  203. X    char line[BUFSIZ];
  204. X
  205. X    while (fgets(line, sizeof line, in) != NULL)
  206. X        if (anchored)
  207. X            status |= gngp(pattern, line);
  208. X        else {
  209. X            register char *start;
  210. X
  211. X            for (start = line; *start != '\0'; start++)
  212. X                status |= gngp(pattern, start);
  213. X        }
  214. X    return status;
  215. X}
  216. X
  217. Xint
  218. Xgngp(pattern, text)
  219. Xregister char *pattern, *text;
  220. X{
  221. X    int returned;
  222. X    char savewhite;
  223. X    char *whitesp;
  224. X
  225. X    if (anchored) {
  226. X        extern char *strpbrk();
  227. X
  228. X        whitesp = strpbrk(text, " \t\n");
  229. X        if (whitesp != NULL) {
  230. X            savewhite = *whitesp;
  231. X            *whitesp = '\0';
  232. X        }
  233. X    }
  234. X    returned = ngmatch(pattern, text);
  235. X    if (anchored) {
  236. X        if (whitesp != NULL)
  237. X            *whitesp = savewhite;
  238. X    }
  239. X    if (returned)
  240. X        (void) fputs(text, stdout);
  241. X    return returned;
  242. X}
  243. END_OF_FILE
  244. if test 1988 -ne `wc -c <'gngp/gngp.c'`; then
  245.     echo shar: \"'gngp/gngp.c'\" unpacked with wrong size!
  246. fi
  247. # end of 'gngp/gngp.c'
  248. fi
  249. if test -f 'libc/error.3' -a "${1}" != "-c" ; then 
  250.   echo shar: Will not clobber existing file \"'libc/error.3'\"
  251. else
  252. echo shar: Extracting \"'libc/error.3'\" \(1621 characters\)
  253. sed "s/^X//" >'libc/error.3' <<'END_OF_FILE'
  254. X.TH ERROR 3 local
  255. X.DA 8 May 1984
  256. X.SH NAME
  257. Xerror, warning \- print error messages
  258. X.SH SYNOPSIS
  259. X.nf
  260. X.B error(s1, s2)
  261. X.B char *s1;
  262. X.B char *s2;
  263. X
  264. X.B warning(s1, s2)
  265. X.B char *s1;
  266. X.B char *s2;
  267. X
  268. X.B extern char *progname;
  269. X.B extern int errno;
  270. X
  271. X.B progname = argv[0];
  272. X.SH DESCRIPTION
  273. X.I Warning
  274. Xprints an error message, with suitable embellishments,
  275. Xand clears
  276. X.IR errno .
  277. X.I Error
  278. Xdoes likewise and then exits.
  279. XThe
  280. X.I s1
  281. Xargument should be a
  282. X.I printf
  283. Xformat string (without a trailing newline), with
  284. X.I s2
  285. Xavailable as an argument.
  286. X.PP
  287. XIf there is an environment variable
  288. X.BR CMDNAME
  289. Xwith non-null value,
  290. Xits contents are printed first, followed by a colon.
  291. XFollowing this,
  292. Xany non-null value of
  293. X.I progname
  294. Xis printed, followed by a colon and a space.
  295. XFollowing this,
  296. X.IR fprintf (3)
  297. Xis invoked with
  298. X.I s1
  299. Xas the format string and
  300. X.I s2
  301. Xas the argument.
  302. XIf the value of
  303. X.I errno
  304. Xis within the normal range,
  305. Xa standard elaborating message is printed (see
  306. X.IR intro (2)).
  307. X.PP
  308. X.B CMDNAME
  309. Xshould be set by shellfiles that expect subordinate programs to
  310. Xissue error message in the shellfile's name.
  311. X.I Progname
  312. Xshould be set by all programs;
  313. X.I argv[0]
  314. Xis usually a suitable thing to set it to.
  315. X.I Errno
  316. Xis set by system calls and various other routines,
  317. Xalthough its use is not universal;
  318. Xnote that it is not reset by successful system calls following an
  319. Xunsuccessful one.
  320. X.SH SEE ALSO
  321. Xintro(2), intro(3), printf(3), exit(2), getopt(3)
  322. X.SH DIAGNOSTICS
  323. X.IR Error 's
  324. Xexit status is 1.
  325. X.SH HISTORY
  326. XLocal products, modelled on the
  327. X.I error
  328. Xin Kernighan&Pike.
  329. X.SH BUGS
  330. XBe nice if they could take a full
  331. X.IR printf -style
  332. Xargument list.
  333. END_OF_FILE
  334. if test 1621 -ne `wc -c <'libc/error.3'`; then
  335.     echo shar: \"'libc/error.3'\" unpacked with wrong size!
  336. fi
  337. # end of 'libc/error.3'
  338. fi
  339. if test -f 'libc/fgetmfs.3' -a "${1}" != "-c" ; then 
  340.   echo shar: Will not clobber existing file \"'libc/fgetmfs.3'\"
  341. else
  342. echo shar: Extracting \"'libc/fgetmfs.3'\" \(1406 characters\)
  343. sed "s/^X//" >'libc/fgetmfs.3' <<'END_OF_FILE'
  344. X.TH FGETMFS 3 local "Public Domain"
  345. X.DA 3 August 1987
  346. X.SH NAME
  347. Xfgetmfs \- read an arbitrarily long, possibly continued line
  348. X.SH SYNOPSIS
  349. X.B "#include <stdio.h>
  350. X.br
  351. X.B "#include <fgetmfs.h>
  352. X.PP
  353. X.B "char *fgetmfs(stream, cont)"
  354. X.br
  355. X.B "FILE *stream;"
  356. X.br
  357. X.B "int cont;"
  358. X.SH DESCRIPTION
  359. X.I Fgetmfs
  360. Xreads an arbitrarily long line from
  361. X.IR stream ,
  362. Xallocating memory via
  363. X.IR malloc (3)
  364. Xas needed.
  365. XFor efficiency,
  366. Xif
  367. X.I cont
  368. Xis not
  369. X.IR CONT_NO ,
  370. Xsuch as
  371. X.I CONT_NOSPC
  372. Xor
  373. X.IR CONT_SPC ,
  374. Xoccurrences of a backslash and a newline together
  375. Xand in that order
  376. Xwill be deleted from the input stream;
  377. Xif
  378. X.I cont
  379. Xis
  380. X.IR CONT_NOSPC ,
  381. Xany whitespace after the newline
  382. Xin the input stream will also be deleted from it.
  383. X.PP
  384. X.I Fgetmfs
  385. Xis intended to provide a reliable mechanism for reading
  386. Xinput containing lines of arbitrary length,
  387. Xrather than trusting that no line with be longer than some
  388. Xarbitrary tolerance.
  389. X.PP
  390. XThe memory returned by
  391. X.I fgetmfs
  392. Xshould be returned when no longer needed via
  393. X.IR free (3).
  394. X.\" .SH FILES
  395. X.SH SEE ALSO
  396. X.IR malloc (3),
  397. X.IR fgets (3)
  398. X.SH DIAGNOSTICS
  399. XReturns NULL (0) if memory cannot be allocated or upon reading end-of-file;
  400. Xuse
  401. X.I feof(stream)
  402. Xto distinguish.
  403. X.SH HISTORY
  404. XWritten by Geoff Collyer
  405. Xat the University of Toronto
  406. Xas part of the C news project.
  407. X.SH BUGS
  408. XIt's too slow.
  409. X.br
  410. XThe meaning of the
  411. X.I cont
  412. Xflag is ugly,
  413. Xbut layering this form of continuation on top is even slower.
  414. END_OF_FILE
  415. if test 1406 -ne `wc -c <'libc/fgetmfs.3'`; then
  416.     echo shar: \"'libc/fgetmfs.3'\" unpacked with wrong size!
  417. fi
  418. # end of 'libc/fgetmfs.3'
  419. fi
  420. if test -f 'libc/memcpy.fast/src/duff.longs.c' -a "${1}" != "-c" ; then 
  421.   echo shar: Will not clobber existing file \"'libc/memcpy.fast/src/duff.longs.c'\"
  422. else
  423. echo shar: Extracting \"'libc/memcpy.fast/src/duff.longs.c'\" \(1420 characters\)
  424. sed "s/^X//" >'libc/memcpy.fast/src/duff.longs.c' <<'END_OF_FILE'
  425. X#define LUMP long
  426. X
  427. Xmemcpy(to, from, count)    /* assumes unaligned LUMPs can be copied */
  428. Xregister char *from, *to;
  429. Xregister int count;
  430. X{
  431. X    /*
  432. X     * This code uses Duff's Device (tm Tom Duff)
  433. X     * to unroll the copying loop:
  434. X     * while (count-- > 0)
  435. X     *    *to++ = *from++;
  436. X     * Sorry the code is so ugly.
  437. X     */
  438. X    if (count > 0) {
  439. X        register LUMP *fromlump = (LUMP *)from, *tolump = (LUMP *)to;
  440. X        register int inloops;
  441. X        register int loops = count >> 3;    /* /8 */
  442. X
  443. X        count %= 8;        /* about to copy loops*8 bytes */
  444. X        inloops = (loops+8-1) >> 3;    /* /8 round up */
  445. X#define COPY8BYTES    *tolump++ = *fromlump++; \
  446. X            *tolump++ = *fromlump++
  447. X        if (loops > 0) {
  448. X            switch (loops&(8-1)) {    /* %8 */
  449. X            case 0:    do {
  450. X                    COPY8BYTES;
  451. X                case 7:    COPY8BYTES;
  452. X                case 6:    COPY8BYTES;
  453. X                case 5:    COPY8BYTES;
  454. X                case 4:    COPY8BYTES;
  455. X                case 3:    COPY8BYTES;
  456. X                case 2:    COPY8BYTES;
  457. X                case 1:    COPY8BYTES;
  458. X                } while (--inloops > 0);
  459. X            }
  460. X            from = (char *)fromlump;
  461. X            to = (char *)tolump;
  462. X        }
  463. X    }
  464. X    /*
  465. X     * This code uses Duff's Device (tm Tom Duff)
  466. X     * to unroll the copying loop the last count%8 times:
  467. X     * while (count-- > 0)
  468. X     *    *to++ = *from++;
  469. X     * Sorry the code is so ugly.
  470. X     */
  471. X    if (count > 0) {
  472. X        switch (count&(8-1)) {    /* %8 */
  473. X        case 0:
  474. X#define COPYBYTE *to++ = *from++
  475. X                COPYBYTE;
  476. X            case 7:    COPYBYTE;
  477. X            case 6:    COPYBYTE;
  478. X            case 5:    COPYBYTE;
  479. X            case 4:    COPYBYTE;
  480. X            case 3:    COPYBYTE;
  481. X            case 2:    COPYBYTE;
  482. X            case 1:    COPYBYTE;
  483. X        }
  484. X    }
  485. X}
  486. END_OF_FILE
  487. if test 1420 -ne `wc -c <'libc/memcpy.fast/src/duff.longs.c'`; then
  488.     echo shar: \"'libc/memcpy.fast/src/duff.longs.c'\" unpacked with wrong size!
  489. fi
  490. # end of 'libc/memcpy.fast/src/duff.longs.c'
  491. fi
  492. if test -f 'libc/standard.3' -a "${1}" != "-c" ; then 
  493.   echo shar: Will not clobber existing file \"'libc/standard.3'\"
  494. else
  495. echo shar: Extracting \"'libc/standard.3'\" \(1641 characters\)
  496. sed "s/^X//" >'libc/standard.3' <<'END_OF_FILE'
  497. X.TH STANDARD 3 local
  498. X.DA 9 Feb 1982
  499. X.SH NAME
  500. Xstandard, safe \- standardize conditions in preparation for exec
  501. X.SH SYNOPSIS
  502. X.B standard()
  503. X.PP
  504. X.B safe()
  505. X.SH DESCRIPTION
  506. X.I Standard
  507. Xalters a process's environment to make it relatively safe to do
  508. X.IR execvp ,
  509. X.IR system ,
  510. X.IR popen ,
  511. Xetc.
  512. XIt closes all descriptors except
  513. Xthe standard ones and supplies a standard set of environment variables
  514. Xthat ensure a standard interpretation of shell commands and a
  515. Xstandard search path for programs.
  516. X.PP
  517. X.I Safe
  518. Xis similar, but is intended for use in shell escapes and suchlike.
  519. XIt leaves the environment variables untouched but turns off
  520. Xsetuid and setgid permissions.
  521. X.PP
  522. XUse of either one permits a setuid/setgid program to
  523. Xrun other programs without inadvertently bestowing special powers
  524. Xon nonstandard programs.
  525. XCare must still be exercised as to what the standard descriptors
  526. Xrefer to,
  527. Xand it is still possible for
  528. Xprograms executed after use of
  529. X.I standard
  530. X(as opposed to
  531. X.IR safe )
  532. Xto give away special powers through
  533. X.I their
  534. Xcarelessness.
  535. X.SH SEE ALSO
  536. Xenviron(3), closeall(3)
  537. X.SH HISTORY
  538. XLocal products.
  539. X.SH BUGS
  540. X.I Standard
  541. Xmust necessarily supply standard values for some environment variables,
  542. Xbut it is not clear whether it should pass other variables
  543. Xthrough or eliminate them.
  544. XThe current implementation eliminates them, which is safer but sometimes
  545. Xinconvenient.
  546. X.PP
  547. XOne can construct elaborate scenarios in which a setuid
  548. Xprogram employing
  549. X.I safe
  550. Xcould be duped into
  551. Xexecuting a user-supplied program in a current directory
  552. Xthe user ordinarily could not have reached.
  553. X.PP
  554. XPossibly
  555. Xone or both should standardize the
  556. X.I umask
  557. Xsetting.
  558. END_OF_FILE
  559. if test 1641 -ne `wc -c <'libc/standard.3'`; then
  560.     echo shar: \"'libc/standard.3'\" unpacked with wrong size!
  561. fi
  562. # end of 'libc/standard.3'
  563. fi
  564. if test -f 'libc/strings/string.h.proto' -a "${1}" != "-c" ; then 
  565.   echo shar: Will not clobber existing file \"'libc/strings/string.h.proto'\"
  566. else
  567. echo shar: Extracting \"'libc/strings/string.h.proto'\" \(1489 characters\)
  568. sed "s/^X//" >'libc/strings/string.h.proto' <<'END_OF_FILE'
  569. X/*
  570. X * String functions.
  571. X */
  572. X
  573. XVOIDSTAR memcpy(/*VOIDSTAR dst, const VOIDSTAR src, SIZET size*/);
  574. XVOIDSTAR memccpy(/*VOIDSTAR dst, const VOIDSTAR src, int ucharstop, SIZET size*/);
  575. Xchar *strcpy(/*char *dst, const char *src*/);
  576. Xchar *strncpy(/*char *dst, const char *src, SIZET size*/);
  577. Xchar *strcat(/*char *dst, const char *src*/);
  578. Xchar *strncat(/*char *dst, const char *src, SIZET size*/);
  579. Xint memcmp(/*const VOIDSTAR s1, const VOIDSTAR s2, SIZET size*/);
  580. Xint strcmp(/*const char *s1, const char *s2*/);
  581. Xint strncmp(/*const char *s1, const char *s2, SIZET size*/);
  582. XVOIDSTAR memchr(/*const VOIDSTAR s, int ucharwanted, SIZET size*/);
  583. Xchar *strchr(/*const char *s, int charwanted*/);
  584. XSIZET strcspn(/*const char *s, const char *reject*/);
  585. Xchar *strpbrk(/*const char *s, const char *breakat*/);
  586. Xchar *strrchr(/*const char *s, int charwanted*/);
  587. XSIZET strspn(/*const char *s, const char *accept*/);
  588. Xchar *strstr(/*const char *s, const char *wanted*/);
  589. Xchar *strtok(/*char *s, const char *delim*/);
  590. XVOIDSTAR memset(/*VOIDSTAR s, int ucharfill, SIZET size*/);
  591. XSIZET strlen(/*const char *s*/);
  592. X
  593. X/*
  594. X * V7 and Berklix compatibility.
  595. X */
  596. Xchar *index(/*const char *s, int charwanted*/);
  597. Xchar *rindex(/*const char *s, int charwanted*/);
  598. Xint bcopy(/*const char *src, char *dst, int length*/);
  599. Xint bcmp(/*const char *s1, const char *s2, int length*/);
  600. Xint bzero(/*char *dst, int length*/);
  601. X
  602. X/*
  603. X * Putting this in here is really silly, but who am I to argue with X3J11?
  604. X */
  605. Xchar *strerror(/*int errnum*/);
  606. END_OF_FILE
  607. if test 1489 -ne `wc -c <'libc/strings/string.h.proto'`; then
  608.     echo shar: \"'libc/strings/string.h.proto'\" unpacked with wrong size!
  609. fi
  610. # end of 'libc/strings/string.h.proto'
  611. fi
  612. if test -f 'libcnews/lock.c' -a "${1}" != "-c" ; then 
  613.   echo shar: Will not clobber existing file \"'libcnews/lock.c'\"
  614. else
  615. echo shar: Extracting \"'libcnews/lock.c'\" \(1717 characters\)
  616. sed "s/^X//" >'libcnews/lock.c' <<'END_OF_FILE'
  617. X/*
  618. X * C news system locking.
  619. X * It's compatible with B 2.10.1 news, except that locks are never
  620. X * declared stale (blow 'em away in /etc/rc).
  621. X * Only permit rnews to run on a file server to make this sane.
  622. X */
  623. X
  624. X#include <stdio.h>
  625. X#include <errno.h>
  626. X#include <sys/types.h>
  627. X#include "news.h"
  628. X
  629. X#define LOCKNAME "LOCK"
  630. X#define LOCKTEMP "LOCKTMXXXXXX"
  631. X#define INTERVAL 25        /* seconds to sleep on a busy lock */
  632. X
  633. Xstatic int debug = NO;
  634. Xstatic int mylock = NO;
  635. X
  636. Xlockdebug(state)
  637. Xint state;
  638. X{
  639. X    debug = state;
  640. X}
  641. X
  642. Xnewslock()
  643. X{
  644. X    int locktries = 0;
  645. X    char tempnm[MAXFILE], lockfile[MAXFILE];
  646. X    FILE *tempfp;
  647. X    extern int errno;
  648. X    char *libfile();
  649. X    char *strcpy(), *mktemp();
  650. X
  651. X    /* create temporary name for linking; store my pid in it */
  652. X    (void) strcpy(tempnm, libfile(LOCKTEMP));
  653. X    (void) mktemp(tempnm);
  654. X    tempfp = fopen(tempnm, "w");
  655. X    if (tempfp == NULL)
  656. X        error("can't create lock temporary `%s'", tempnm);
  657. X    (void) fprintf(tempfp, "%d\n", getpid());
  658. X    (void) fclose(tempfp);
  659. X
  660. X    /* repeatedly try to link the temporary name to LOCKNAME */
  661. X    (void) strcpy(lockfile, libfile(LOCKNAME));
  662. X    while (link(tempnm, lockfile) < 0) {
  663. X        extern char *progname;
  664. X
  665. X        if (errno != EEXIST)
  666. X            error("can't link `%s' to LOCK", tempnm);
  667. X        /*
  668. X         * Decide here if lock is stale.
  669. X         * If so, remove it and try again to lock.
  670. X         */
  671. X        /* process still alive */
  672. X        if (debug && ++locktries == 1)
  673. X            (void) printf("%s: sleeping on LOCK\n", progname);
  674. X        sleep(INTERVAL);
  675. X    }
  676. X    (void) unlink(tempnm);
  677. X    mylock = YES;
  678. X}
  679. X
  680. Xnewsunlock()
  681. X{
  682. X    char *libfile();
  683. X
  684. X    if (mylock) {
  685. X        (void) unlink(libfile(LOCKNAME));
  686. X        mylock = NO;
  687. X    }
  688. X}
  689. X
  690. Xerrunlock(fmt, s)        /* like error(3), but unlock before exit */
  691. Xchar *fmt, *s;
  692. X{
  693. X    warning(fmt, s);
  694. X    newsunlock();
  695. X    exit(1);
  696. X    /* NOTREACHED */
  697. X}
  698. END_OF_FILE
  699. if test 1717 -ne `wc -c <'libcnews/lock.c'`; then
  700.     echo shar: \"'libcnews/lock.c'\" unpacked with wrong size!
  701. fi
  702. # end of 'libcnews/lock.c'
  703. fi
  704. if test -f 'libcnews/readline.c' -a "${1}" != "-c" ; then 
  705.   echo shar: Will not clobber existing file \"'libcnews/readline.c'\"
  706. else
  707. echo shar: Extracting \"'libcnews/readline.c'\" \(1904 characters\)
  708. sed "s/^X//" >'libcnews/readline.c' <<'END_OF_FILE'
  709. X/*
  710. X * readline - like fgets, but newslock at first EOF
  711. X */
  712. X
  713. X#include <stdio.h>
  714. X#include <signal.h>
  715. X#include <sys/types.h>
  716. X#include "news.h"
  717. X
  718. Xvoid complain();
  719. X
  720. X/* How to get an unsigned char. */
  721. X#ifdef CHARBITS
  722. X#define    UCHARAT(p)    (*(p)&CHARBITS)
  723. X#else
  724. X#define    UCHARAT(p)    ((int)*(unsigned char *)(p))
  725. X#endif
  726. X
  727. Xint nlocked = 0;        /* newslock() done? read by the caller */
  728. X
  729. X/* Buffer etc. for readline and friends. */
  730. Xstatic char buf[BUFSIZ];
  731. Xstatic int nleft = 0;
  732. Xstatic char *rest;
  733. X
  734. X/*
  735. X - readline - read a line (sans newline), with locking when we hit EOF
  736. X *
  737. X * Minor flaw:  will lose a last line which lacks a newline.
  738. X */
  739. Xint                /* 0 success, -1 final EOF */
  740. Xreadline(s, n, fd)
  741. Xchar *s;
  742. Xint n;
  743. Xint fd;                /* Note descriptor, not FILE *. */
  744. X{
  745. X    register char *dst;
  746. X    register int ndst;
  747. X    register int c;
  748. X    extern void refill();
  749. X    extern int errno;
  750. X
  751. X    dst = s;
  752. X    for (ndst = n-1; ndst > 0; ndst--) {    /* -1 for NUL */
  753. X        if (nleft <= 0) {
  754. X            refill(fd);
  755. X            if (nleft <= 0)    /* refill gave up. */
  756. X                return -1;
  757. X        }
  758. X        c = UCHARAT(rest);
  759. X        rest++;
  760. X        nleft--;
  761. X
  762. X        if (c == '\n') {
  763. X            *dst++ = '\0';
  764. X            return 0;
  765. X        } else
  766. X            *dst++ = c;
  767. X    }
  768. X
  769. X    *dst++ = '\0';
  770. X    errno = 0;
  771. X    complain("over-long history line `%s'", s);
  772. X    return 0;
  773. X}
  774. X
  775. X/*
  776. X - refill - refill readline's buffer, with locking on EOF
  777. X */
  778. Xvoid
  779. Xrefill(fd)
  780. Xint fd;
  781. X{
  782. X    register int ret;
  783. X
  784. X    /* Just in case... */
  785. X    if (nleft > 0)
  786. X        return;
  787. X
  788. X    /* Try ordinary read. */
  789. X    ret = read(fd, buf, (int)sizeof(buf));
  790. X    if (ret < 0) {
  791. X        complain("read error in history", "");
  792. X        return;
  793. X    }
  794. X    if (ret > 0) {
  795. X        nleft = ret;
  796. X        rest = buf;
  797. X        return;
  798. X    }
  799. X
  800. X    /* EOF. */
  801. X    if (nlocked)
  802. X        return;        /* We're really done. */
  803. X
  804. X    /* EOF but we haven't locked yet.  Lock and try again. */
  805. X    (void) signal(SIGINT, (sigarg_t)SIG_IGN);
  806. X    (void) signal(SIGQUIT, (sigarg_t)SIG_IGN);
  807. X    (void) signal(SIGHUP, (sigarg_t)SIG_IGN);
  808. X    (void) signal(SIGTERM, (sigarg_t)SIG_IGN);
  809. X    newslock();
  810. X    nlocked = 1;
  811. X    refill(fd);
  812. X}
  813. END_OF_FILE
  814. if test 1904 -ne `wc -c <'libcnews/readline.c'`; then
  815.     echo shar: \"'libcnews/readline.c'\" unpacked with wrong size!
  816. fi
  817. # end of 'libcnews/readline.c'
  818. fi
  819. if test -f 'mail/coder/uuencode.c' -a "${1}" != "-c" ; then 
  820.   echo shar: Will not clobber existing file \"'mail/coder/uuencode.c'\"
  821. else
  822. echo shar: Extracting \"'mail/coder/uuencode.c'\" \(1989 characters\)
  823. sed "s/^X//" >'mail/coder/uuencode.c' <<'END_OF_FILE'
  824. X/* based on 5.1 (Berkeley) 7/2/83 */
  825. X
  826. X/*
  827. X * uuencode [input] output
  828. X *
  829. X * Encode a file so it can be mailed to a remote system.
  830. X */
  831. X#include <stdio.h>
  832. X#include <sys/types.h>
  833. X#include <sys/stat.h>
  834. X
  835. Xmain(argc, argv)
  836. Xchar **argv;
  837. X{
  838. X    FILE *in;
  839. X    struct stat sbuf;
  840. X    int mode;
  841. X
  842. X    /* optional 1st argument */
  843. X    if (argc > 2) {
  844. X        if ((in = fopen(argv[1], "r")) == NULL) {
  845. X            perror(argv[1]);
  846. X            exit(1);
  847. X        }
  848. X        argv++; argc--;
  849. X    } else
  850. X        in = stdin;
  851. X
  852. X    if (argc != 2) {
  853. X        (void) fprintf(stderr, "Usage: uuencode [infile] remotefile\n");
  854. X        exit(2);
  855. X    }
  856. X
  857. X    /* figure out the input file mode */
  858. X    (void) fstat(fileno(in), &sbuf);
  859. X    mode = sbuf.st_mode & 0777;
  860. X    (void) printf("begin %o %s\n", mode, argv[1]);
  861. X
  862. X    encode(in, stdout);
  863. X
  864. X    (void) printf("end\n");
  865. X    exit(0);
  866. X}
  867. X
  868. X/*
  869. X * copy from in to out, encoding as you go along.
  870. X */
  871. Xencode(in, out)
  872. XFILE *in;
  873. XFILE *out;
  874. X{
  875. X    register char *ibp, *obp;
  876. X    register int inbyte, outbyte;
  877. X    register char *ibufend;
  878. X    register int incount;
  879. X    char inbuf[45+1+3];        /* +3 is due to sloppy for test */
  880. X    char outbuf[1+60+1+1];        /* len+text+newline */
  881. X
  882. X/* ENC is the basic 1 character encoding function to make a char printing */
  883. X#define ENC(c) (((c) & 077) + ' ')    /* N.B.: c is evaluated exactly once. */
  884. X
  885. X    do {
  886. X        incount = fread(inbuf, 1, 45, in);
  887. X        ibp = inbuf;
  888. X        obp = outbuf;
  889. X        *obp++ = ENC(incount);
  890. X        for (ibufend = inbuf + incount; ibp < ibufend; ) {
  891. X            /*
  892. X             * Encode (as 4 bytes pointed at by obp) one group
  893. X             * of 3 bytes pointed at by ibp.
  894. X             * Code is obscure to make it blaze along (sorry).
  895. X             * Each "*obp++ = ENC(...)" emits the next 6 bits of
  896. X             * the input bytes.
  897. X             */
  898. X            *obp++ = ENC((inbyte = *ibp++) >> 2);
  899. X            outbyte = (inbyte << 4) /* & 060 */ ;
  900. X            *obp++ = ENC(outbyte | (((inbyte = *ibp++) >> 4) & 017));
  901. X            outbyte = (inbyte << 2) /* & 074 */ ;
  902. X            *obp++ = ENC(outbyte | (((inbyte = *ibp++) >> 6) & 03));
  903. X            *obp++ = ENC(inbyte /* & 077 */ );
  904. X        }
  905. X        *obp++ = '\n';
  906. X        *obp = '\0';
  907. X        (void) fwrite(outbuf, 1, obp - outbuf, out);
  908. X    } while (incount > 0);
  909. X}
  910. END_OF_FILE
  911. if test 1989 -ne `wc -c <'mail/coder/uuencode.c'`; then
  912.     echo shar: \"'mail/coder/uuencode.c'\" unpacked with wrong size!
  913. fi
  914. # end of 'mail/coder/uuencode.c'
  915. fi
  916. if test -f 'newsbin.proto/control/newgroup' -a "${1}" != "-c" ; then 
  917.   echo shar: Will not clobber existing file \"'newsbin.proto/control/newgroup'\"
  918. else
  919. echo shar: Extracting \"'newsbin.proto/control/newgroup'\" \(1152 characters\)
  920. sed "s/^X//" >'newsbin.proto/control/newgroup' <<'END_OF_FILE'
  921. X#! /bin/sh
  922. X# newgroup group - create group (4-field version: B-2.10.3 and later compatible)
  923. X#    subject to our sys file group pattern
  924. X# B 2.11 requires an Approved: header; someday.
  925. XNEWSCTL=${NEWSCTL-/usr/lib/news}; export NEWSCTL
  926. XNEWSBIN=${NEWSBIN-/usr/lib/newsbin}; export NEWSBIN
  927. XNEWSARTS=${NEWSARTS-/usr/spool/news}; export NEWSARTS
  928. XPATH=/bin:/usr/bin:/usr/ucb:$NEWSCTL:$NEWSBIN; export PATH    # must find mkpdir
  929. XF=/tmp/nc$$
  930. Xadmin=usenet
  931. X
  932. Xcat >$F
  933. XSENDER="`grep '^Sender:' $F | sed 's/^[^:]*: *//'`"
  934. Xcase "$SENDER" in
  935. X"")
  936. X    SENDER="`grep '^From:' $F | sed 's/^[^:]*: *//'`"
  937. X    ;;
  938. Xesac
  939. X
  940. Xif grep -s "^`echo $1 | sed 's/\./\\\\./g'` " $NEWSCTL/active; then    # group exists
  941. X    : do nothing
  942. Xelif gngp -a `
  943. X    egrep "^(\`hostname\`|ME):" $NEWSCTL/sys | awk -F: '{print $2; exit}'
  944. X    ` >/dev/null <<!
  945. X$1
  946. X!
  947. Xthen            # no group in active, but sys file likes it: make it
  948. X    case "$2" in
  949. X    moderated)    flag=m ;;
  950. X    *)    flag=y ;;
  951. X    esac
  952. X    echo "$1 00000 00000 $flag" >>$NEWSCTL/active
  953. X    # TODO: is it worth making the directory now? maybe, rn bitches otherwise
  954. X    mkpdir $NEWSARTS/`echo $1 | sed 's/\./\//g' `
  955. X    echo "newsgroup $1 was created by $SENDER." | mail $admin
  956. Xfi
  957. X
  958. Xrm -f $F*
  959. END_OF_FILE
  960. if test 1152 -ne `wc -c <'newsbin.proto/control/newgroup'`; then
  961.     echo shar: \"'newsbin.proto/control/newgroup'\" unpacked with wrong size!
  962. fi
  963. # end of 'newsbin.proto/control/newgroup'
  964. fi
  965. if test -f 'newsbin.proto/control/newgroup.4' -a "${1}" != "-c" ; then 
  966.   echo shar: Will not clobber existing file \"'newsbin.proto/control/newgroup.4'\"
  967. else
  968. echo shar: Extracting \"'newsbin.proto/control/newgroup.4'\" \(1152 characters\)
  969. sed "s/^X//" >'newsbin.proto/control/newgroup.4' <<'END_OF_FILE'
  970. X#! /bin/sh
  971. X# newgroup group - create group (4-field version: B-2.10.3 and later compatible)
  972. X#    subject to our sys file group pattern
  973. X# B 2.11 requires an Approved: header; someday.
  974. XNEWSCTL=${NEWSCTL-/usr/lib/news}; export NEWSCTL
  975. XNEWSBIN=${NEWSBIN-/usr/lib/newsbin}; export NEWSBIN
  976. XNEWSARTS=${NEWSARTS-/usr/spool/news}; export NEWSARTS
  977. XPATH=/bin:/usr/bin:/usr/ucb:$NEWSCTL:$NEWSBIN; export PATH    # must find mkpdir
  978. XF=/tmp/nc$$
  979. Xadmin=usenet
  980. X
  981. Xcat >$F
  982. XSENDER="`grep '^Sender:' $F | sed 's/^[^:]*: *//'`"
  983. Xcase "$SENDER" in
  984. X"")
  985. X    SENDER="`grep '^From:' $F | sed 's/^[^:]*: *//'`"
  986. X    ;;
  987. Xesac
  988. X
  989. Xif grep -s "^`echo $1 | sed 's/\./\\\\./g'` " $NEWSCTL/active; then    # group exists
  990. X    : do nothing
  991. Xelif gngp -a `
  992. X    egrep "^(\`hostname\`|ME):" $NEWSCTL/sys | awk -F: '{print $2; exit}'
  993. X    ` >/dev/null <<!
  994. X$1
  995. X!
  996. Xthen            # no group in active, but sys file likes it: make it
  997. X    case "$2" in
  998. X    moderated)    flag=m ;;
  999. X    *)    flag=y ;;
  1000. X    esac
  1001. X    echo "$1 00000 00000 $flag" >>$NEWSCTL/active
  1002. X    # TODO: is it worth making the directory now? maybe, rn bitches otherwise
  1003. X    mkpdir $NEWSARTS/`echo $1 | sed 's/\./\//g' `
  1004. X    echo "newsgroup $1 was created by $SENDER." | mail $admin
  1005. Xfi
  1006. X
  1007. Xrm -f $F*
  1008. END_OF_FILE
  1009. if test 1152 -ne `wc -c <'newsbin.proto/control/newgroup.4'`; then
  1010.     echo shar: \"'newsbin.proto/control/newgroup.4'\" unpacked with wrong size!
  1011. fi
  1012. # end of 'newsbin.proto/control/newgroup.4'
  1013. fi
  1014. if test -f 'newshist/newshist.c' -a "${1}" != "-c" ; then 
  1015.   echo shar: Will not clobber existing file \"'newshist/newshist.c'\"
  1016. else
  1017. echo shar: Extracting \"'newshist/newshist.c'\" \(1312 characters\)
  1018. sed "s/^X//" >'newshist/newshist.c' <<'END_OF_FILE'
  1019. X/*
  1020. X * newshist msgids - print history lines corresponding to msgids
  1021. X */
  1022. X
  1023. X#include <stdio.h>
  1024. X#include "history.h"
  1025. X
  1026. Xchar *progname;
  1027. Xint debug;
  1028. Xstatic char *history;        /* unused */
  1029. Xint remote;            /* to satisfy rnews code */
  1030. X
  1031. X/*
  1032. X * main - parse arguments and handle options
  1033. X */
  1034. Xmain(argc, argv)
  1035. Xint argc;
  1036. Xchar *argv[];
  1037. X{
  1038. X    int c;
  1039. X    int errflg = 0;
  1040. X    extern int optind;
  1041. X    extern char *optarg;
  1042. X
  1043. X    progname = argv[0];
  1044. X    while ((c = getopt(argc, argv, "df:")) != EOF)
  1045. X        switch (c) {
  1046. X        case 'd':
  1047. X            ++debug;
  1048. X            break;
  1049. X        case 'f':
  1050. X            history = optarg;
  1051. X            break;
  1052. X        default:
  1053. X            errflg++;
  1054. X            break;
  1055. X        }
  1056. X    if (optind == argc || errflg) {
  1057. X        fprintf(stderr, "usage: %s [-df file]\n", progname);
  1058. X        exit(2);
  1059. X    }
  1060. X
  1061. X    for (; optind < argc; optind++)
  1062. X        process(argv[optind]);
  1063. X    exit(0);
  1064. X}
  1065. X
  1066. X/*
  1067. X * process - message-id argument
  1068. X */
  1069. Xprocess(msgid)
  1070. Xchar *msgid;
  1071. X{
  1072. X    char *histent;
  1073. X
  1074. X    if (msgid == NULL)
  1075. X        return;        
  1076. X    histent = gethistory(msgid);
  1077. X    if (histent == NULL) {
  1078. X        char newmsgid[1000];
  1079. X        extern char *strcpy(), *strcat();
  1080. X
  1081. X        (void) strcpy(newmsgid, "<");
  1082. X        (void) strcat(newmsgid, msgid);
  1083. X        (void) strcat(newmsgid, ">");
  1084. X        histent = gethistory(newmsgid);
  1085. X    }
  1086. X    if (histent == NULL)
  1087. X        fprintf(stderr, "%s: no history entry for %s nor <%s>\n",
  1088. X            progname, msgid, msgid);
  1089. X    else
  1090. X        fputs(histent, stdout);
  1091. X    (void) fflush(stdout);
  1092. X}
  1093. X
  1094. Xunprivileged()
  1095. X{
  1096. X}
  1097. END_OF_FILE
  1098. if test 1312 -ne `wc -c <'newshist/newshist.c'`; then
  1099.     echo shar: \"'newshist/newshist.c'\" unpacked with wrong size!
  1100. fi
  1101. # end of 'newshist/newshist.c'
  1102. fi
  1103. if test -f 'rna/makefile' -a "${1}" != "-c" ; then 
  1104.   echo shar: Will not clobber existing file \"'rna/makefile'\"
  1105. else
  1106. echo shar: Extracting \"'rna/makefile'\" \(2018 characters\)
  1107. sed "s/^X//" >'rna/makefile' <<'END_OF_FILE'
  1108. XDEFINES=-Dstrchr=index -Dstrrchr=rindex
  1109. XCFLAGS=-O $(DEFINES) # -s is a stupid idea
  1110. XINSTALL=:# install bigpdp
  1111. XNFLAG =
  1112. XI=/usr/include
  1113. XC=/lib/libc.a
  1114. XLIBS=lib/*.a
  1115. XLIBDIR=/usr/lib/news
  1116. XBINDIR=/bin
  1117. XCOMMANDS = postnews uurec readnews uusend expire postgroup
  1118. XFILES = help
  1119. XLCOMMANDS = postnews.lint uurec.lint readnews.lint uusend.lint expire.lint
  1120. XPFILES = header.c postnews.c funcs.c active.c history.c maketime.c mtempnam.c
  1121. XRFILES = header.c readnews.c funcs.c active.c newsrc.c history.c maketime.c
  1122. XROFILES= header.o readnews.o funcs.o active.o newsrc.o history.o maketime.o
  1123. XEFILES = expire.c funcs.c active.c
  1124. XLINT = lint -ha $(DEFINES)
  1125. X
  1126. X.c.lint:
  1127. X    $(LINT) $< > $@
  1128. X
  1129. X.c:
  1130. X    $(CC) $(CFLAGS) $*.c $(NFLAG) -o $(@F)
  1131. X    $(INSTALL) $* bin 711 $@
  1132. X
  1133. X.sh:
  1134. X    $(INSTALL) -c $*.sh bin 755 $@
  1135. X
  1136. Xall: defs.h $(LIBDIR) $(COMMANDS) $(FILES)
  1137. X
  1138. Xdefs.h:    at.h $C
  1139. X    touch defs.h
  1140. X
  1141. X$(LIBDIR):
  1142. X    mkdir $(LIBDIR)
  1143. X    chown news $(LIBDIR)
  1144. X    chmod 755 $(LIBDIR)
  1145. X
  1146. Xlint: $(LCOMMANDS)
  1147. X
  1148. Xhelp: $(LIBDIR)/help
  1149. X$(LIBDIR)/help: news.help
  1150. X    $(INSTALL) -c news.help news 644 $(LIBDIR)/help
  1151. X
  1152. Xpostnews: $(BINDIR)/postnews
  1153. X$(BINDIR)/postnews: $(PFILES) defs.h
  1154. X    $(CC) $(CFLAGS) $(PFILES) -o postnews
  1155. X    $(INSTALL) - postnews news 6711 $(BINDIR)/postnews
  1156. X
  1157. Xpostgroup: $(BINDIR)/postgroup
  1158. X$(BINDIR)/postgroup: postgroup.sh
  1159. X
  1160. Xuurec: $(LIBDIR)/uurec
  1161. X$(LIBDIR)/uurec: uurec.c defs.h
  1162. X
  1163. Xreadnews: $(BINDIR)/readnews
  1164. X$(BINDIR)/readnews: $(ROFILES) defs.h
  1165. X    $(CC) $(CFLAGS) $(ROFILES) $(LIBS) -o readnews
  1166. X    $(INSTALL) - readnews bin 711 $(BINDIR)/readnews $(BINDIR)/news
  1167. X$(ROFILES): defs.h
  1168. X
  1169. Xuusend: $(LIBDIR)/uusend
  1170. X$(LIBDIR)/uusend: defs.h uusend.c
  1171. X
  1172. Xexpire: $(LIBDIR)/expire
  1173. X$(LIBDIR)/expire: $(EFILES) defs.h
  1174. X    $(CC) $(CFLAGS) $(EFILES) $(NFLAG) -o expire
  1175. X    $(INSTALL) expire news 700 $(LIBDIR)/expire
  1176. X
  1177. Xpostnews.lint: $(PFILES)
  1178. X    $(LINT) $(PFILES) > postnews.lint
  1179. X
  1180. Xreadnews.lint: $(RFILES)
  1181. X    $(LINT) $(RFILES) > readnews.lint
  1182. X
  1183. Xexpire.lint: $(EFILES)
  1184. X    $(LINT) $(EFILES) > expire.lint
  1185. X
  1186. Xuurec.lint: uurec.c defs.h
  1187. Xuusend.lint: uusend.c defs.h
  1188. X
  1189. X.FINISH:
  1190. X    rm -s *.o
  1191. Xclean:
  1192. X    rm -f *.o core a.out readnews
  1193. END_OF_FILE
  1194. if test 2018 -ne `wc -c <'rna/makefile'`; then
  1195.     echo shar: \"'rna/makefile'\" unpacked with wrong size!
  1196. fi
  1197. # end of 'rna/makefile'
  1198. fi
  1199. if test -f 'rna/mtempnam.c' -a "${1}" != "-c" ; then 
  1200.   echo shar: Will not clobber existing file \"'rna/mtempnam.c'\"
  1201. else
  1202. echo shar: Extracting \"'rna/mtempnam.c'\" \(1295 characters\)
  1203. sed "s/^X//" >'rna/mtempnam.c' <<'END_OF_FILE'
  1204. X/*
  1205. X * same as usual tempnam.c except force placement in the directory
  1206. X * we ask for
  1207. X */
  1208. X#include <stdio.h>
  1209. X
  1210. X#ifndef P_tmpdir
  1211. X#define P_tmpdir    "/tmp/"
  1212. X#define L_tmpnam    (sizeof(P_tmpdir) + 15)
  1213. X#endif
  1214. X
  1215. X#define max(A,B) (((A)<(B))?(B):(A))
  1216. X
  1217. Xextern char *malloc(), *getenv(), *mktemp();
  1218. Xextern char *strncat(), *strcat(), *strcpy();
  1219. Xextern int access();
  1220. X
  1221. Xstatic char *pcopy(), *seed = "AAA";
  1222. X
  1223. Xchar *
  1224. Xmtempnam(dir, pfx)
  1225. Xchar *dir;        /* use this directory please (if non-NULL) */
  1226. Xchar *pfx;        /* use this (if non-NULL) as filename prefix */
  1227. X{
  1228. X    register char *p, *q;
  1229. X    int x = 0, y = 0, z;
  1230. X
  1231. X    z = strlen(P_tmpdir);
  1232. X    if (dir != NULL) {
  1233. X        y = strlen(dir);
  1234. X    }
  1235. X    if ((p = malloc((unsigned)(max(max(x, y), z) + 16))) == NULL)
  1236. X        return(NULL);
  1237. X    if (y > 0 && pcopy(p, dir))
  1238. X        goto OK;
  1239. X    if (access(pcopy(p, P_tmpdir), 3) == 0)
  1240. X        goto OK;
  1241. X    if (access(pcopy(p, "/tmp"), 3) != 0)
  1242. X        return(NULL);
  1243. XOK:
  1244. X    strcat(p, "/");
  1245. X    if (pfx) {
  1246. X        *(p + strlen(p) + 5) = '\0';
  1247. X        strncat(p, pfx, 5);
  1248. X    }
  1249. X    strcat(p, seed);
  1250. X    strcat(p, "XXXXXX");
  1251. X    q = seed;
  1252. X    while (*q == 'Z')
  1253. X        *q++ = 'A';
  1254. X    ++ * q;
  1255. X    if (*mktemp(p) == '\0')
  1256. X        return(NULL);
  1257. X    return(p);
  1258. X}
  1259. X
  1260. X
  1261. Xstatic char *
  1262. Xpcopy(space, arg)
  1263. Xchar *space, *arg;
  1264. X{
  1265. X    char *p;
  1266. X
  1267. X    if (arg) {
  1268. X        strcpy(space, arg);
  1269. X        p = space - 1 + strlen(space);
  1270. X        if (*p == '/')
  1271. X            *p = '\0';
  1272. X    }
  1273. X    return(space);
  1274. X}
  1275. X
  1276. X
  1277. END_OF_FILE
  1278. if test 1295 -ne `wc -c <'rna/mtempnam.c'`; then
  1279.     echo shar: \"'rna/mtempnam.c'\" unpacked with wrong size!
  1280. fi
  1281. # end of 'rna/mtempnam.c'
  1282. fi
  1283. if test -f 'rna/rnews.sh' -a "${1}" != "-c" ; then 
  1284.   echo shar: Will not clobber existing file \"'rna/rnews.sh'\"
  1285. else
  1286. echo shar: Extracting \"'rna/rnews.sh'\" \(1301 characters\)
  1287. sed "s/^X//" >'rna/rnews.sh' <<'END_OF_FILE'
  1288. X#
  1289. X# rnews  (M. J. Liebelt, University of Adelaide, May 1984)
  1290. X#
  1291. X# netgets files sent to "news" as "newsitem"s and pipes them into
  1292. X# postnews, then reads any mail sent to "news" and pipes that into
  1293. X# $LIBDIR/uurec, which passes the news portions onto postnews.
  1294. X#
  1295. X# It should be run as "/etc/su news rnews " (i.e. with uid = news)
  1296. X#
  1297. X# News should be sent to news at this host from remote hosts thus:
  1298. X#      ... | /usr/lib/news/uusend news:thishost   (to send by mail, or)
  1299. X#      ... | net -hthishost -nnews -f -Nnewsitem -M
  1300. X#
  1301. X#    where "thishost" is the NETID of this host.
  1302. X#
  1303. X# LIBDIR - same as LIBDIR in Makefile
  1304. X# BINDIR - same as BINDIR in Makefile
  1305. X# NETDIR - where netget lives
  1306. XLIBDIR=/usr/lib/news
  1307. XBINDIR=/bin
  1308. XNETDIR=/bin
  1309. X
  1310. Xcd %news
  1311. X
  1312. Xwhile $NETDIR/netget newsitem > /dev/null 2>&1
  1313. Xdo
  1314. X        $BINDIR/postnews -p < newsitem > rnews.errors 2>&1
  1315. X        if [ -s rnews.errors ]
  1316. X        then
  1317. X               cat $LIBDIR/rnews.mail1 rnews.errors $LIBDIR/rnews.mail2 newsitem | mail root
  1318. X        fi
  1319. Xdone
  1320. X
  1321. Xif [ -r .mail ]
  1322. Xthen {
  1323. X        mv .mail newsmail
  1324. X        $LIBDIR/uurec < newsmail > rnews.errors 2>&1
  1325. X        if [ -s rnews.errors ]
  1326. X        then
  1327. X                cat $LIBDIR/rnews.mail1 rnews.errors $LIBDIR/rnews.mail2 newsmail | mail root
  1328. X        fi
  1329. X        }
  1330. Xfi
  1331. X
  1332. Xrm -f newsitem newsmail rnews.errors
  1333. END_OF_FILE
  1334. if test 1301 -ne `wc -c <'rna/rnews.sh'`; then
  1335.     echo shar: \"'rna/rnews.sh'\" unpacked with wrong size!
  1336. fi
  1337. # end of 'rna/rnews.sh'
  1338. fi
  1339. if test -f 'rnews/headers.h' -a "${1}" != "-c" ; then 
  1340.   echo shar: Will not clobber existing file \"'rnews/headers.h'\"
  1341. else
  1342. echo shar: Extracting \"'rnews/headers.h'\" \(1551 characters\)
  1343. sed "s/^X//" >'rnews/headers.h' <<'END_OF_FILE'
  1344. X/*
  1345. X * All the article header values worth retaining.
  1346. X *
  1347. X * All members of hdrs must point at malloced memory so that freeheaders
  1348. X * can free it without knowledge of what's malloced and what's static.
  1349. X * Furthermore, each member of hdrs must point at its own private copy
  1350. X * of its value string, for the above reason, and no other part of inews
  1351. X * may copy any member nor a modified copy of any member.
  1352. X * Perhaps C++ will allow this to be enforced by a strings class.
  1353. X */
  1354. Xstruct headers {
  1355. X    char *h_subj;        /* subject - only needed for controls */
  1356. X    char *h_ngs;        /* newsgroups */
  1357. X    char h_files[MAXLINE];    /* file names for history */
  1358. X    char *h_distr;        /* distribution for transmit */
  1359. X    char *h_ctlcmd;        /* control command */
  1360. X    char *h_approved;    /* needed for acceptance in moderated groups */
  1361. X    char *h_msgid;        /* needed for history & rejection */
  1362. X    char *h_artid;        /* needed for history & rejection (obs.) */
  1363. X    char *h_expiry;        /* needed for history */
  1364. X    char *h_path;        /* needed for transmit - must munge */
  1365. X    char h_tmpf[MAXFILE];    /* temp link name or first spool dir link */
  1366. X    char h_unlink;        /* flag: true iff h_tmpf should be unlinked */
  1367. X    char h_filed;        /* flag: true iff article has been filed */
  1368. X    char h_xref;        /* flag: true iff Xref: header generated yet */
  1369. X    char h_octlchked;    /* flag: true iff ngs checked for all.all.ctl */
  1370. X    char h_oldctl;        /* flag: true iff ngs were all.all.ctl when checked */
  1371. X    char *h_accum;        /* accumulated headers, if any */
  1372. X    unsigned h_bytesleft;    /* in h_accum */
  1373. X    long h_charswritten;    /* into spool directory, for batcher */
  1374. X};
  1375. END_OF_FILE
  1376. if test 1551 -ne `wc -c <'rnews/headers.h'`; then
  1377.     echo shar: \"'rnews/headers.h'\" unpacked with wrong size!
  1378. fi
  1379. # end of 'rnews/headers.h'
  1380. fi
  1381. if test -f 'rnews/man/rnews.1' -a "${1}" != "-c" ; then 
  1382.   echo shar: Will not clobber existing file \"'rnews/man/rnews.1'\"
  1383. else
  1384. echo shar: Extracting \"'rnews/man/rnews.1'\" \(1506 characters\)
  1385. sed "s/^X//" >'rnews/man/rnews.1' <<'END_OF_FILE'
  1386. X.TH RNEWS 1 Usenet "Public Domain"
  1387. X.DA 22 Aug 1987
  1388. X.SH NAME
  1389. Xrnews, cunbatch \- receive `remote' news articles
  1390. X.SH SYNOPSIS
  1391. X.B rnews
  1392. X.SH DESCRIPTION
  1393. X.I Rnews
  1394. Xbroadcasts (network) news articles
  1395. X(receives `\fIr\fPemote'
  1396. X.IR news )
  1397. Xfrom its standard input.
  1398. X.I Cunbatch
  1399. Xis just a link to
  1400. X.IR rnews .
  1401. XTypically the articles will be in a batch
  1402. X(see
  1403. X.IR news (5)),
  1404. Xwhich may be compressed
  1405. X(see
  1406. X.IR compress (1)).
  1407. X.PP
  1408. XTypically articles are stored locally
  1409. Xand queued for transmission to one's netnews neighbours via
  1410. X.IR newsbatch (1)
  1411. Xand thence via
  1412. X.IR uux (1)
  1413. Xor
  1414. X.IR mail (1).
  1415. X.SH FILES
  1416. X.PD 0
  1417. X.TP 1.5i
  1418. X.I $NEWSARTS
  1419. Xnetnews article tree
  1420. X.TP 1.5i
  1421. X.IB $NEWSCTL /sys
  1422. Xdetermines who receives broadcast netnews articles
  1423. X.TP 1.5i
  1424. X.IB $NEWSCTL /active
  1425. Xcontains locally-legal newsgroups and (un)moderated flag
  1426. X.TP 1.5i
  1427. X.IB $NEWSCTL /log
  1428. Xlog of incoming articles
  1429. X.TP 1.5i
  1430. X.IB $NEWSCTL /errlog
  1431. Xlog of errors, should be empty
  1432. X.PD
  1433. X.SH "SEE ALSO"
  1434. X.IR compress (1),
  1435. X.IR mail (1),
  1436. X.IR newsbatch (1),
  1437. X.IR uux (1),
  1438. X.IR news (5)
  1439. X.SH DIAGNOSTICS
  1440. XBatches which generate
  1441. X.I rnews
  1442. Xerrors will be mailed to
  1443. X.IR usenet ,
  1444. Xwho should rerun them by hand after fixing the problem.
  1445. X.br
  1446. XIf
  1447. X.I compress
  1448. Xis not found by the standard PATH,
  1449. Xcompressed news batches may be mailed to
  1450. X.IR usenet .
  1451. X.SH HISTORY
  1452. XWritten by Geoff Collyer
  1453. Xat the University of Toronto
  1454. Xas part of the C news project.
  1455. X.SH BUGS
  1456. X.I Rnews
  1457. Xcould run much faster if
  1458. X.I Control:
  1459. Xwere required to be the first header,
  1460. Xif present,
  1461. Xand if
  1462. X.I Newsgroups:
  1463. Xwere required to be the next.
  1464. END_OF_FILE
  1465. if test 1506 -ne `wc -c <'rnews/man/rnews.1'`; then
  1466.     echo shar: \"'rnews/man/rnews.1'\" unpacked with wrong size!
  1467. fi
  1468. # end of 'rnews/man/rnews.1'
  1469. fi
  1470. if test -f 'rnews/realrnews' -a "${1}" != "-c" ; then 
  1471.   echo shar: Will not clobber existing file \"'rnews/realrnews'\"
  1472. else
  1473. echo shar: Extracting \"'rnews/realrnews'\" \(1318 characters\)
  1474. sed "s/^X//" >'rnews/realrnews' <<'END_OF_FILE'
  1475. X#! /bin/sh
  1476. X# realrnews - receive remote news & relay: feeds incoming news to C news serverrnews
  1477. XNEWSCTL=${NEWSCTL-/usr/lib/news}    # export NEWSCTL
  1478. XNEWSBIN=${NEWSBIN-/usr/lib/newsbin}    # export NEWSBIN
  1479. XNEWSARTS=${NEWSARTS-/usr/spool/news}    # export NEWSARTS
  1480. XPATH=$NEWSCTL:$NEWSBIN:$NEWSBIN/relay:/bin:/usr/bin:/usr/local; export PATH
  1481. XNOTIFY=usenet
  1482. XF=/tmp/rnews$$            # should be lots of room here
  1483. XDEBUG=''
  1484. X
  1485. Xumask 2
  1486. Xtrap '' 1 2 15            # ignore signals to avoid losing articles
  1487. X
  1488. X# don't allow options
  1489. Xcase "$1" in
  1490. X-*)
  1491. X    echo "usage: $0" >&2
  1492. X    exit 1
  1493. X    ;;
  1494. Xesac
  1495. X
  1496. X# capture incoming news in case serverrnews fails
  1497. Xif cat $* >$F; then
  1498. X    if uncompress <$F >$F.un; then
  1499. X        mv $F.un $F    # $F was compressed
  1500. X    else
  1501. X        rm $F.un    # $F was uncompressed already
  1502. X    fi
  1503. X    # -p redirects stdout & stderr into log files
  1504. X    if serverrnews -p -d "$DEBUG" <$F # -s $NEWSARTS -l $NEWSCTL
  1505. X    then
  1506. X        rm -f $F    # far out, it worked
  1507. X    else
  1508. X        status=$?
  1509. X        FAIL=$F.m
  1510. X        (cat <<!; sed 's/^/X/' $F; echo ---) >$FAIL
  1511. Xsubject: failed news; serverrnews status $status
  1512. X
  1513. X---
  1514. X!
  1515. X        if mail $NOTIFY <$FAIL; then
  1516. X            rm -f $FAIL    # $NOTIFY got told about the failure
  1517. X        else
  1518. X            # leave $FAIL and $F around to be seen
  1519. X            mail $NOTIFY <<!
  1520. Xlook at $FAIL and $F, they are lost news.
  1521. X!
  1522. X        fi
  1523. X    fi
  1524. Xelse
  1525. X    status=$?
  1526. X    (echo "subject: lost news; cat status $status"; echo; cat $F) |
  1527. X        mail $NOTIFY
  1528. Xfi
  1529. END_OF_FILE
  1530. if test 1318 -ne `wc -c <'rnews/realrnews'`; then
  1531.     echo shar: \"'rnews/realrnews'\" unpacked with wrong size!
  1532. fi
  1533. # end of 'rnews/realrnews'
  1534. fi
  1535. if test -f 'rnews/setnewsids/setnewsids.c' -a "${1}" != "-c" ; then 
  1536.   echo shar: Will not clobber existing file \"'rnews/setnewsids/setnewsids.c'\"
  1537. else
  1538. echo shar: Extracting \"'rnews/setnewsids/setnewsids.c'\" \(2009 characters\)
  1539. sed "s/^X//" >'rnews/setnewsids/setnewsids.c' <<'END_OF_FILE'
  1540. X/*
  1541. X * setnewsids - sets ids to news/news, execs relay/relaynews.  Should be setuid-root.
  1542. X *    also add NEWSPERMS to the environment.
  1543. X */
  1544. X
  1545. X#include <stdio.h>
  1546. X#include <errno.h>
  1547. X#include <pwd.h>
  1548. X#include <grp.h>
  1549. X#include <sys/types.h>
  1550. X
  1551. X#include "news.h"
  1552. X#include "newspaths.h"
  1553. X
  1554. X#ifndef NEWSUSER
  1555. X#define NEWSUSER "news"
  1556. X#endif
  1557. X#ifndef NEWSGROUP
  1558. X#define NEWSGROUP "news"
  1559. X#endif
  1560. X
  1561. Xchar *progname;
  1562. X
  1563. Xstatic int userealids = NO;
  1564. X
  1565. X/*
  1566. X * main - parse arguments and handle options
  1567. X */
  1568. Xmain(argc, argv)
  1569. Xint argc;
  1570. Xchar *argv[];
  1571. X{
  1572. X    extern int optind;
  1573. X    extern char *optarg;
  1574. X
  1575. X    progname = argv[0];
  1576. X
  1577. X    /* setuid daemon prelude; various precautions */
  1578. X    (void) umask(newsumask());    /* undo silly umasks */
  1579. X    (void) alarm(0);        /* cancel any pending alarm */
  1580. X    /*
  1581. X     * Reset certain environment variables to sane values.
  1582. X     */
  1583. X    if (!putenv("PATH=/bin:/usr/bin") ||
  1584. X        !putenv("IFS= \t\n"))
  1585. X        exit(1);
  1586. X    closeall(1);            /* closes all but std descriptors */
  1587. X    stdfdopen();            /* ensure standard descriptors are open */
  1588. X
  1589. X    setids();            /* change of real and effective ids */
  1590. X    /* we are now running as news, so you can all relax */
  1591. X
  1592. X    if (!putenv("NEWSPERMS="))    /* avoid loops with this marker */
  1593. X        exit(1);
  1594. X    execv(binfile("relay/relaynews"), argv);    /* re-run relay/relaynews */
  1595. X    error("can't exec %s", binfile("relay/relaynews"));
  1596. X}
  1597. X
  1598. Xsetids()                /* change of real and effective ids */
  1599. X{
  1600. X    int newsuid = getuid(), newsgid = getgid();    /* default to real ids */
  1601. X
  1602. X    (void) ctlfile((char *)NULL);    /* trigger unprivileged(), set userealids */
  1603. X    if (!userealids) {
  1604. X        register struct passwd *pwp;
  1605. X        register struct group *grp;
  1606. X
  1607. X        pwp = getpwnam(NEWSUSER);
  1608. X        if (pwp != NULL) {
  1609. X            newsuid = pwp->pw_uid;
  1610. X            newsgid = pwp->pw_gid;
  1611. X        }
  1612. X        (void) endpwent();
  1613. X        grp = getgrnam(NEWSGROUP);
  1614. X        if (grp != NULL)
  1615. X            newsgid = grp->gr_gid;
  1616. X        (void) endgrent();
  1617. X    }
  1618. X    (void) setgid(newsgid);
  1619. X    (void) setuid(newsuid);
  1620. X    /* we are now running as news, so you can all relax */
  1621. X}
  1622. X
  1623. Xvoid
  1624. Xunprivileged()            /* called if NEWSARTS, NEWSCTL or NEWSBIN present */
  1625. X{
  1626. X    userealids = YES;
  1627. X}
  1628. END_OF_FILE
  1629. if test 2009 -ne `wc -c <'rnews/setnewsids/setnewsids.c'`; then
  1630.     echo shar: \"'rnews/setnewsids/setnewsids.c'\" unpacked with wrong size!
  1631. fi
  1632. # end of 'rnews/setnewsids/setnewsids.c'
  1633. fi
  1634. if test -f 'rnews/sh/realrnews' -a "${1}" != "-c" ; then 
  1635.   echo shar: Will not clobber existing file \"'rnews/sh/realrnews'\"
  1636. else
  1637. echo shar: Extracting \"'rnews/sh/realrnews'\" \(1318 characters\)
  1638. sed "s/^X//" >'rnews/sh/realrnews' <<'END_OF_FILE'
  1639. X#! /bin/sh
  1640. X# realrnews - receive remote news & relay: feeds incoming news to C news serverrnews
  1641. XNEWSCTL=${NEWSCTL-/usr/lib/news}    # export NEWSCTL
  1642. XNEWSBIN=${NEWSBIN-/usr/lib/newsbin}    # export NEWSBIN
  1643. XNEWSARTS=${NEWSARTS-/usr/spool/news}    # export NEWSARTS
  1644. XPATH=$NEWSCTL:$NEWSBIN:$NEWSBIN/relay:/bin:/usr/bin:/usr/local; export PATH
  1645. XNOTIFY=usenet
  1646. XF=/tmp/rnews$$            # should be lots of room here
  1647. XDEBUG=''
  1648. X
  1649. Xumask 2
  1650. Xtrap '' 1 2 15            # ignore signals to avoid losing articles
  1651. X
  1652. X# don't allow options
  1653. Xcase "$1" in
  1654. X-*)
  1655. X    echo "usage: $0" >&2
  1656. X    exit 1
  1657. X    ;;
  1658. Xesac
  1659. X
  1660. X# capture incoming news in case serverrnews fails
  1661. Xif cat $* >$F; then
  1662. X    if uncompress <$F >$F.un; then
  1663. X        mv $F.un $F    # $F was compressed
  1664. X    else
  1665. X        rm $F.un    # $F was uncompressed already
  1666. X    fi
  1667. X    # -p redirects stdout & stderr into log files
  1668. X    if serverrnews -p -d "$DEBUG" <$F # -s $NEWSARTS -l $NEWSCTL
  1669. X    then
  1670. X        rm -f $F    # far out, it worked
  1671. X    else
  1672. X        status=$?
  1673. X        FAIL=$F.m
  1674. X        (cat <<!; sed 's/^/X/' $F; echo ---) >$FAIL
  1675. Xsubject: failed news; serverrnews status $status
  1676. X
  1677. X---
  1678. X!
  1679. X        if mail $NOTIFY <$FAIL; then
  1680. X            rm -f $FAIL    # $NOTIFY got told about the failure
  1681. X        else
  1682. X            # leave $FAIL and $F around to be seen
  1683. X            mail $NOTIFY <<!
  1684. Xlook at $FAIL and $F, they are lost news.
  1685. X!
  1686. X        fi
  1687. X    fi
  1688. Xelse
  1689. X    status=$?
  1690. X    (echo "subject: lost news; cat status $status"; echo; cat $F) |
  1691. X        mail $NOTIFY
  1692. Xfi
  1693. END_OF_FILE
  1694. if test 1318 -ne `wc -c <'rnews/sh/realrnews'`; then
  1695.     echo shar: \"'rnews/sh/realrnews'\" unpacked with wrong size!
  1696. fi
  1697. # end of 'rnews/sh/realrnews'
  1698. fi
  1699. if test -f 'rnews/speed/disk/active.c' -a "${1}" != "-c" ; then 
  1700.   echo shar: Will not clobber existing file \"'rnews/speed/disk/active.c'\"
  1701. else
  1702. echo shar: Extracting \"'rnews/speed/disk/active.c'\" \(1426 characters\)
  1703. sed "s/^X//" >'rnews/speed/disk/active.c' <<'END_OF_FILE'
  1704. X/*
  1705. X * active file access functions (on-disk version)
  1706. X */
  1707. X
  1708. X#include <stdio.h>
  1709. X#include "inews.h"
  1710. X
  1711. Xstatic FILE *fp = NULL;
  1712. X
  1713. Xlong
  1714. Xnxtartnum(ng)
  1715. Xchar *ng;
  1716. X{
  1717. X    return incartnum(ng, 1);
  1718. X}
  1719. X
  1720. Xlong
  1721. Xprevartnum(ng)
  1722. Xchar *ng;
  1723. X{
  1724. X    return incartnum(ng, -1);
  1725. X}
  1726. X
  1727. Xstatic long
  1728. Xincartnum(ng, inc)
  1729. Xchar *ng;
  1730. Xint inc;
  1731. X{
  1732. X    register int nglen = strlen(ng);
  1733. X    register long pos, nextart = -1;
  1734. X    char line[MAXLINE];
  1735. X    extern char ldzeropad[];
  1736. X    long atol();
  1737. X
  1738. X    if (artload() != ST_OKAY)
  1739. X        return nextart;
  1740. X#ifdef MICROLOCKING
  1741. X    filelock(libfile("active"));
  1742. X#endif
  1743. X    (void) fseek(fp, 0L, 0);    /* start at the start */
  1744. X    for (pos = ftell(fp); fgets(line, sizeof line, fp) != NULL;
  1745. X         pos = ftell(fp))
  1746. X        if (strncmp(line, ng, nglen) == 0 &&
  1747. X            line[nglen] == ' ') {
  1748. X            nextart = atol(&line[nglen + 1]) + inc;
  1749. X            (void) fseek(fp, pos, 0);    /* back up */
  1750. X            (void) fprintf(fp, "%s ", ng);
  1751. X            (void) fprintf(fp, ldzeropad,
  1752. X                ARTNUMWIDTH, ARTNUMWIDTH, nextart);
  1753. X            (void) fflush(fp);
  1754. X            break;
  1755. X        }
  1756. X#ifdef MICROLOCKING
  1757. X    fileunlock(libfile("active"));
  1758. X#endif
  1759. X    return nextart;
  1760. X}
  1761. X
  1762. Xint
  1763. Xartload()                /* reload any cached data */
  1764. X{
  1765. X    int status = 0;
  1766. X    char *libfile();
  1767. X    FILE *fopenwclex();
  1768. X
  1769. X    if (fp == NULL)
  1770. X        if ((fp = fopenwclex(libfile("active"), "r+")) == NULL)
  1771. X            status |= ST_DROPPED;
  1772. X    return status;
  1773. X}
  1774. X
  1775. Xint
  1776. Xartsync()                /* sync to disk any cached data */
  1777. X{
  1778. X    int status = 0;
  1779. X
  1780. X    if (fp != NULL && fclose(fp) == EOF)
  1781. X        status |= ST_DROPPED;
  1782. X    fp = NULL;
  1783. X    return status;
  1784. X}
  1785. END_OF_FILE
  1786. if test 1426 -ne `wc -c <'rnews/speed/disk/active.c'`; then
  1787.     echo shar: \"'rnews/speed/disk/active.c'\" unpacked with wrong size!
  1788. fi
  1789. # end of 'rnews/speed/disk/active.c'
  1790. fi
  1791. if test -f 'rnews/speed/disk/sys.c' -a "${1}" != "-c" ; then 
  1792.   echo shar: Will not clobber existing file \"'rnews/speed/disk/sys.c'\"
  1793. else
  1794. echo shar: Extracting \"'rnews/speed/disk/sys.c'\" \(1710 characters\)
  1795. sed "s/^X//" >'rnews/speed/disk/sys.c' <<'END_OF_FILE'
  1796. X/*
  1797. X * inews sys file reading functions (on-disk version)
  1798. X */
  1799. X
  1800. X#include <stdio.h>
  1801. X#include "inews.h"
  1802. X#include "system.h"
  1803. X
  1804. Xstatic FILE *fp = NULL;        /* descriptor for libfile("sys") */
  1805. X
  1806. Xstruct system *
  1807. Xoursys()            /* return our sys entry */
  1808. X{
  1809. X    register struct system *sys;
  1810. X    static struct system fakesys;
  1811. X    char *rindex();
  1812. X    char *hostname();
  1813. X    struct system *nextsys();
  1814. X
  1815. X    rewsys();
  1816. X    while ((sys = nextsys()) != NULL &&
  1817. X        strcmp(sys->sy_name, hostname()) != 0)
  1818. X        ;
  1819. X    if (sys == NULL) {        /* no entry; cook one up */
  1820. X        fakesys.sy_name = hostname();
  1821. X        fakesys.sy_ngs = "all";
  1822. X        fakesys.sy_flags = "";
  1823. X        fakesys.sy_cmd = "";
  1824. X        sys = &fakesys;
  1825. X    }
  1826. X    return sys;
  1827. X}
  1828. X
  1829. X/*
  1830. X * Returned pointer points at a static struct whose members
  1831. X * point at static storage.
  1832. X */
  1833. Xstruct system *
  1834. Xnextsys()            /* return next sys entry */
  1835. X{
  1836. X    register char *s;
  1837. X    register char **sp;
  1838. X    static char sysent[MAXLINE];
  1839. X    static struct system sys;    /* pointers into sysent */
  1840. X    char *strcpy(), *strcat(), *rindex();
  1841. X    char *hostname(), *libfile();
  1842. X    FILE *fopenwclex();
  1843. X
  1844. X    if (fp == NULL)
  1845. X        if ((fp = fopenwclex(libfile("sys"), "r")) == NULL)
  1846. X            return NULL;
  1847. X    while ((s = fgets(sysent, sizeof sysent, fp)) != NULL)
  1848. X        if (s[0] != '#')        /* not a comment */
  1849. X            break;
  1850. X    if (s == NULL)
  1851. X        return NULL;
  1852. X
  1853. X    s = rindex(sysent, '\n');
  1854. X    if (s != NULL)
  1855. X        *s = '\0';        /* trim newline */
  1856. X    sp = &sys.sy_name;        /* point at string pointers */
  1857. X    *sp++ = sysent;
  1858. X    for (s = sysent; *s != '\0'; s++)
  1859. X        if (*s == ':') {
  1860. X            *s = '\0';    /* turn colons into NULs */
  1861. X            if (sp <= &sys.sy_cmd)
  1862. X                *sp++ = s + 1;    /* point at next field */
  1863. X        }
  1864. X    for (; sp <= &sys.sy_cmd; sp++)
  1865. X        *sp = "";        /* fill remaining fields */
  1866. X    return &sys;
  1867. X}
  1868. X
  1869. Xrewsys()
  1870. X{
  1871. X    if (fp != NULL)
  1872. X        (void) fseek(fp, 0L, 0);
  1873. X}
  1874. END_OF_FILE
  1875. if test 1710 -ne `wc -c <'rnews/speed/disk/sys.c'`; then
  1876.     echo shar: \"'rnews/speed/disk/sys.c'\" unpacked with wrong size!
  1877. fi
  1878. # end of 'rnews/speed/disk/sys.c'
  1879. fi
  1880. if test -f 'rnews/test/lib/sys' -a "${1}" != "-c" ; then 
  1881.   echo shar: Will not clobber existing file \"'rnews/test/lib/sys'\"
  1882. else
  1883. echo shar: Extracting \"'rnews/test/lib/sys'\" \(1751 characters\)
  1884. sed "s/^X//" >'rnews/test/lib/sys' <<'END_OF_FILE'
  1885. X# ourselves: accept everything but noise and ut.stardate from U. Texas
  1886. Xutcs:all,!ut.stardate,!net.philosophy,!net.politics,!net.religion,!net.flame,!net.bizarre,net.music.synth,!net.music,!net.audio,!net.abortion,!net.movies,!net.women,!net.sf-lovers,!net.origins
  1887. X# our news feed: send everything & locally-written articles go direct
  1888. Xutzoo:net,comp,news,sci,rec,misc,soc,talk,mod,world,na,can,ont,tor,ut,to.utzoo:F:/usr/src/cmd/news/rnews/test/newsbatch/utzoo
  1889. X# sites we feed (no outstanding requests)
  1890. X#    utfyzx gets everything we get
  1891. Xutfyzx:net,comp,news,sci,rec,misc,soc,talk,mod,world,na,can,ont,tor,ut,to.utfyzx:F:/usr/src/cmd/news/rnews/test/newsbatch/utfyzx
  1892. X#    ryesone gets everything we get.
  1893. Xryesone:net,comp,news,sci,rec,misc,soc,talk,mod,world,na,can,ont,tor,ut,to.ryesone:F:/usr/src/cmd/news/rnews/test/newsbatch/ryesone
  1894. X#    bnr-vpa gets everything we get except ut and tor
  1895. Xbnr-vpa:net,comp,news,sci,rec,misc,soc,talk,mod,world,na,can,ont,to.bnr-vpa:F:/usr/src/cmd/news/rnews/test/newsbatch/bnr-vpa
  1896. X#    utcsstat gets a few net groups and local groups
  1897. Xutcsstat:all.sources,mod.computers.sun,mod.computers.ibm-pc,net.unix-wizards,net.announce,net.math,net.physics,net.micro,net.news.config,world,can,ont,tor,ut,to.utcsstat:F:/usr/src/cmd/news/rnews/test/newsbatch/utcsstat
  1898. X#    utcsscb gets a few net groups plus local groups
  1899. Xutcsscb:net.announce,net.micro,net.unix,net.math,net.news.config,world,can,ont,tor,ut,to.utcsscb:F:/usr/src/cmd/news/rnews/test/newsbatch/utcsscb
  1900. X#    lsuc gets ont and net.news.config only.    their primary feed is mnetor.
  1901. Xlsuc:world,ont,net.news.config,to.lsuc:F:/usr/src/cmd/news/rnews/test/newsbatch/lsuc
  1902. X#    mnetor gets everything we post locally except ut
  1903. X#    utcsri gets just articles in local groups or locally-written articles
  1904. END_OF_FILE
  1905. if test 1751 -ne `wc -c <'rnews/test/lib/sys'`; then
  1906.     echo shar: \"'rnews/test/lib/sys'\" unpacked with wrong size!
  1907. fi
  1908. # end of 'rnews/test/lib/sys'
  1909. fi
  1910. if test -f 'rnews/vers/v7/gethostname.c' -a "${1}" != "-c" ; then 
  1911.   echo shar: Will not clobber existing file \"'rnews/vers/v7/gethostname.c'\"
  1912. else
  1913. echo shar: Extracting \"'rnews/vers/v7/gethostname.c'\" \(1379 characters\)
  1914. sed "s/^X//" >'rnews/vers/v7/gethostname.c' <<'END_OF_FILE'
  1915. X/*
  1916. X * v7 gethostname simulation
  1917. X *    taken from pathalias and cleaned up.  Thanks, peter.
  1918. X */
  1919. X
  1920. X#include <stdio.h>
  1921. X
  1922. X#define MAXLINE 256
  1923. X#define min(a,b) ((a) < (b)? (a): (b))
  1924. X
  1925. Xstatic char defhost[] = "INSERT-YOUR-HOST-NAME-HERE";
  1926. X
  1927. Xint
  1928. Xgethostname(hostname, size)
  1929. Xchar *hostname;
  1930. Xint size;
  1931. X{
  1932. X    char *ptr;
  1933. X    FILE *whoami;
  1934. X    char *index(), *strncpy();
  1935. X    FILE *fopen(), *popen();
  1936. X
  1937. X    *hostname = '\0';
  1938. X    /* try /etc/whoami */
  1939. X    if ((whoami = fopen("/etc/whoami", "r")) != NULL) {
  1940. X        (void) fgets(hostname, size, whoami);
  1941. X        (void) fclose(whoami);
  1942. X        if ((ptr = index(hostname, '\n')) != NULL)
  1943. X            *ptr = '\0';
  1944. X    }
  1945. X    if (*hostname != '\0')
  1946. X        return 0;
  1947. X    /* try /usr/include/whoami.h */
  1948. X    if ((whoami = fopen("/usr/include/whoami.h", "r")) != NULL) {
  1949. X        while (!feof(whoami)) {
  1950. X            char sysname[MAXLINE];
  1951. X
  1952. X            if (fgets(sysname, MAXLINE, whoami) == NULL)
  1953. X                break;
  1954. X            if (sscanf(sysname, "#define sysname \"%[^\"]\"",
  1955. X                hostname) > 0)
  1956. X                break;
  1957. X        }
  1958. X        (void) fclose(whoami);
  1959. X        if (*hostname != '\0')
  1960. X            return 0;
  1961. X    }
  1962. X    /* ask uucp */
  1963. X    if ((whoami = popen("PATH=/bin:/usr/bin:/usr/ucb uuname -l", "r")) != NULL) {
  1964. X        (void) fgets(hostname, size, whoami);
  1965. X        (void) pclose(whoami);
  1966. X        if ((ptr = index(hostname, '\n')) != NULL)
  1967. X            *ptr = '\0';
  1968. X    }
  1969. X    if (*hostname != '\0')
  1970. X        return 0;
  1971. X    /* aw hell, i give up!  is this a real unix? */
  1972. X    (void) strncpy(hostname, defhost, min(sizeof defhost, size));
  1973. X    return 0;
  1974. X}
  1975. END_OF_FILE
  1976. if test 1379 -ne `wc -c <'rnews/vers/v7/gethostname.c'`; then
  1977.     echo shar: \"'rnews/vers/v7/gethostname.c'\" unpacked with wrong size!
  1978. fi
  1979. # end of 'rnews/vers/v7/gethostname.c'
  1980. fi
  1981. if test -f 'time/getdate.c' -a "${1}" != "-c" ; then 
  1982.   echo shar: Will not clobber existing file \"'time/getdate.c'\"
  1983. else
  1984. echo shar: Extracting \"'time/getdate.c'\" \(1241 characters\)
  1985. sed "s/^X//" >'time/getdate.c' <<'END_OF_FILE'
  1986. X/*
  1987. X * getdate ascii_time ... - print the time_t of ascii_time(s)
  1988. X */
  1989. X
  1990. X#include <stdio.h>
  1991. X#include <ctype.h>
  1992. X#include <time.h>
  1993. X#include <sys/types.h>
  1994. X#include <sys/timeb.h>
  1995. X
  1996. X#define    DAY    (24L*60L*60L)
  1997. X
  1998. Xstruct timeb ftnow;
  1999. X
  2000. Xchar *progname;
  2001. X
  2002. Xextern int errno;
  2003. Xextern char *strcpy();
  2004. Xextern char *strncpy();
  2005. Xextern char *strcat();
  2006. Xextern char *strchr();
  2007. Xextern char *strtok();
  2008. Xextern long atol();
  2009. Xextern char *malloc();
  2010. Xextern struct tm *gmtime();
  2011. Xextern time_t time();
  2012. X
  2013. Xextern time_t getdate();
  2014. X
  2015. X/* Forwards. */
  2016. Xextern void process();
  2017. X
  2018. X/*
  2019. X - main - parse arguments and handle options
  2020. X */
  2021. Xmain(argc, argv)
  2022. Xint argc;
  2023. Xchar *argv[];
  2024. X{
  2025. X    register int c;
  2026. X    register int errflg = 0;
  2027. X    extern int optind;
  2028. X    extern char *optarg;
  2029. X
  2030. X    progname = argv[0];
  2031. X    ftime(&ftnow);
  2032. X
  2033. X    while ((c = getopt(argc, argv, "")) != EOF)
  2034. X        switch (c) {
  2035. X        case '?':
  2036. X        default:
  2037. X            errflg++;
  2038. X            break;
  2039. X        }
  2040. X    if (errflg || optind == argc) {
  2041. X        (void) fprintf(stderr, "Usage: %s ascii_time ...\n", progname);
  2042. X        exit(2);
  2043. X    }
  2044. X
  2045. X    for (; optind < argc; optind++)
  2046. X        process(argv[optind]);
  2047. X    exit(0);
  2048. X}
  2049. X
  2050. X/*
  2051. X * process - print time_t of tm
  2052. X */
  2053. Xvoid
  2054. Xprocess(tm)
  2055. Xchar *tm;
  2056. X{
  2057. X    time_t it;
  2058. X
  2059. X    it = getdate(tm, &ftnow);
  2060. X    if (it < 0)
  2061. X        error("`%s' not valid date", tm);
  2062. X    else
  2063. X        (void) printf("%ld\n", it);
  2064. X}
  2065. END_OF_FILE
  2066. if test 1241 -ne `wc -c <'time/getdate.c'`; then
  2067.     echo shar: \"'time/getdate.c'\" unpacked with wrong size!
  2068. fi
  2069. # end of 'time/getdate.c'
  2070. fi
  2071. echo shar: End of archive 4 \(of 14\).
  2072. ##  End of shell archive.
  2073. exit 0
  2074.